

** Export tables of results for appendix

***Inputs: 
* $Data/normscore_IV60_ability.dta
* $Results/byage
* $Results/bydomain
* $Results/binary_memory
* $Results/byability
* $Results/binary_ability
* $Results/bylearning

***Outputs: 
* $Results/byage_table.tex
* $Results/domain_table.tex
* $Results/ability_table.tex
* $Results/learning_table.tex



	use $Data/normscore_IV60_ability.dta, clear

	
	keep if maxzipwind<. 
	drop cut_age
	
	egen cut_age = cut(age_sig), at(10(10)81)
	replace cut_age = 70 if age> =80
 
	gen above5play = nth_play >= 5 & nth_play<.

	gen ismemory = gamenum ==77

	
	
		
	xtile abovemedability = residmem,  nq(2)
	by anon_id, sort: egen mmm = min(abovemedability) if gamenum ==77
	
	replace abovemedability = mmm
	drop mmm

	
	label variable highpm "Daily PM2.5 $>$ 25" 
	label variable norm_score "Normalized score"
	label variable highpm "Daily PM2.5 $>$ 25" 
	label variable weighted_dailypm "Daily PM2.5"

	label define domain 55 "Verbal" 74 "Attention" 76 "Flexibility" 77 "Memory"  78  "Math" 84  "Speed" 104 "Problem Solving" 	
	label values gamenum domain 
	
	label define age 10 "$<$20" 20 "20"   30 "30" 40 "40"	  50 "50" 	 60 "60"   70 "$\geq$ 70" 
	label values cut_age age
	
	label define ability  1  "Quintile 1"   2 "Quintile 2" 	  3 "Quintile 3"    4 "Quintile 4"  5 "Quintile 5" 
	label values quinresid ability		 
	
	label define play 0 "First 5 plays" 1 "> 5 plays" 
	label values above5play play
 
	label define ismem 0 "Non memory domains" 1 "Memory domain"
	label values ismemory ismem
	
	label define abovemed 1 "Below median ability" 2 "Above median ability"
	label values abovemedability abovemed
	
	
	
	**order: age domain ability learning
	
	estimates use $Results/byage 
	eststo age 
	
	esttab age using $Results/age_table.tex,  replace se drop(weighted*) nocon star(* 0.1 ** 0.05 *** 0.001) label 
	
	
	
	estimates use $Results/bydomain
	eststo domain
	
	
	estimates use $Results/binary_memory
	eststo bin_domain
	
	
	
	esttab domain bin_domain using $Results/domain_table.tex,  replace se drop(weighted*) nocon star(* 0.1 ** 0.05 *** 0.001) label 
	
	estimates use $Results/byability
	eststo ability
	
	
	
	estimates use $Results/binary_ability
	eststo bin_ability
	
	
	
	esttab ability bin_ability using $Results/ability_table.tex,  replace se drop(weighted*) nocon star(* 0.1 ** 0.05 *** 0.001) label 
	
	
	
	estimates use $Results/bylearning 
	eststo learning
	
	
	esttab learning using $Results/learning_table.tex,  replace se drop(weighted*) nocon star(* 0.1 ** 0.05 *** 0.001) label 
	
	
